@import (reference) '../style/variables.less';

.@{prefix}-navbar {
  position: fixed;
  z-index: 101;
  top: 0;
  left: 0;
  right: 0;
  height: @s-nav-height;
  text-align: center;
  white-space: nowrap;
  background-color: #fff;
  box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.1);
  transition: all 0.2s;

  [data-prefers-color='dark'] & {
    background: @c-bg-dark;
    box-shadow: 0 2px 8px 0 rgba(0, 0, 0, 0.65);
  }

  @media @mobile {
    display: flex;
    justify-content: center;
    height: @s-mobile-nav-height;
  }

  &.hide {
    opacity: 0;
    transform: translateY(-100%);
  }

  &.transparent {
    box-shadow: none;
    background-color: transparent;

    nav > span > a {
      color: #fff;
    }

    .__dumi-kdesign-search-input {
      filter: brightness(150%) opacity(0.7);
      background-color: hsla(0, 0%, 100%, 0.2);
    }

    .__dumi-kdesign-menus-handle {
      filter: brightness(150%);

      &-split {
        background-color: rgba(255, 255, 255, 0.3);
      }
    }
  }
  &.transparent &-main .__dumi-kdesign-right .__dumi-kdesign-version {
    color: #fff;
  }

  &-brand {
    display: flex;
    align-items: center;
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    padding-left: 40px;

    @media @mobile {
      padding-left: 16px;
    }
  }

  &-logo {
    display: inline-block;
    height: 30px;
    width: 197px;
    color: #080e29;
    font-weight: 500;
    text-decoration: none;
    font-size: 24px;
    line-height: 40px;

    [data-prefers-color='dark'] & {
      color: @c-heading-dark;
    }

    &:not([data-plaintext]) {
      background: url(@img-logo) no-repeat 0 / contain;
    }

    @media @mobile {
      height: 28px;
      line-height: 28px;

      &:not([data-plaintext]) {
        padding-left: 36px;
      }
    }
  }

  .__dumi-kdesign-navbar-main {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 1180px;
    margin: 0 auto;

    @media only screen and (max-width: 1200px) {
      width: 95%;
    }

    .__dumi-kdesign-right {
      position: relative;
      .__dumi-kdesign-version {
        @media @mobile {
          display: none;
        }
        padding-left: 20px;
        color: #999;
        font-size: 12px;
      }
    }
  }

  @media only screen and (max-width: 1024px) {
    .__dumi-kdesign-navbar-main {
      .__dumi-kdesign-right {
        position: inherit;
      }
    }
  }

  &-tool {
    display: inline-block;
  }

  nav {
    margin-left: 246px;
    > span {
      position: relative;
      margin-left: 40px;
      display: inline-block;
      color: @c-text;
      height: @s-nav-height;
      cursor: pointer;
      font-size: 14px;
      line-height: @s-nav-height;
      text-decoration: none;
      letter-spacing: 0;

      [data-prefers-color='dark'] & {
        color: @c-text-dark;
      }

      > a {
        color: #333;
        text-decoration: none;

        [data-prefers-color='dark'] & {
          color: @c-heading-dark;
        }

        &:hover,
        &.active {
          color: @c-primary;
          [data-prefers-color='dark'] & {
            color: @c-primary-dark;
          }
        }

        &::before {
          content: '';
          position: absolute;
          top: 0;
          bottom: 0;
          right: -18px;
          left: -18px;
        }

        &.active::after {
          content: '';
          position: absolute;
          bottom: 0;
          left: -2px;
          right: -2px;
          height: 2px;
          background-color: @c-primary;
          border-radius: 1px;
        }
      }

      + *:not(a) {
        margin-left: 40px;
      }

      // second nav
      > ul {
        list-style: none;
        position: absolute;
        top: 100%;
        left: 50%;
        margin: 0;
        min-width: 100px;
        padding: 8px 18px;
        line-height: 2;
        background-color: #fff;
        box-shadow: 0 8px 24px -2px rgba(0, 0, 0, 0.08);
        transform: translate(-50%);
        transform-origin: top;
        border-radius: 1px;
        transition: all 0.2s;

        [data-prefers-color='dark'] & {
          background-color: @c-bg-dark;
        }

        a {
          position: relative;
          display: block;
          color: @c-text;
          text-decoration: none;

          [data-prefers-color='dark'] & {
            color: @c-text-dark;
          }

          &:hover,
          &.active {
            color: @c-primary;

            [data-prefers-color='dark'] & {
              color: @c-primary-dark;
            }
          }
        }
      }

      &:not(:hover) > ul {
        visibility: hidden;
        pointer-events: none;
        transform: translate(-50%) scaleY(0.9);
        opacity: 0;
      }
    }

    .@{prefix}-search + .@{prefix}-locale-select {
      margin-left: 40px;
    }

    @media @mobile {
      > a,
      > span,
      > div {
        display: none;
      }
    }
  }

  &[data-mode='site'] {
    display: block;
  }
}
